package com.icxcc.icxoauth.service.impl;

import com.google.common.collect.Sets;
import com.icxcc.icxoauth.provider.MyUserDetails;
import com.icxcc.icxoauth.service.SysUserService;
import org.springframework.context.annotation.Primary;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Set;

@Primary
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
    @Override
    public UserDetails loadUserByUsername(String username) {

        PasswordEncoder passwordEncoder=new BCryptPasswordEncoder(4);
        Set<GrantedAuthority> authorities = Sets.newHashSet();
        authorities.add(()->"admin");
        authorities.add(()->"edit");
        User user = new User("admin", passwordEncoder.encode("admin"), true, true,true, true,authorities);
        return user;
    }
}
